package org.wzl._360mallbackend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wzl._360mallbackend.dao.DeliveryAddressMapper;
import org.wzl._360mallbackend.entity.DeliveryAddress;
import org.wzl._360mallbackend.utils.Response;

@RestController
@RequestMapping("/delivery")
public class DeliveryController {

    @Autowired
    private DeliveryAddressMapper deliveryAddressMapper;

    @PostMapping("/insert")
    public Response insert(@RequestBody DeliveryAddress deliveryAddress) {
        deliveryAddressMapper.insert(deliveryAddress);
        return Response.ok();
    }

    @GetMapping("/getById")
    public Response getById(Integer id) {
        QueryWrapper<DeliveryAddress> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id" , id);
        return Response.ok()
                .putData("getById",deliveryAddressMapper.selectList(queryWrapper));
    }

}
